package com.wanmait.wisdom.manage.controller;

import com.wanmait.wisdom.entity.Office;
import com.wanmait.wisdom.manage.service.ManageOfficeService;
import com.wanmait.wisdom.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@RestController
@RequestMapping("/manage")
public class ManageOfficeController {
    @Resource
    private ManageOfficeService manageOfficeService;

    @GetMapping("/showAllOffice")
    public AjaxResult showAllOffice(){
        List<Office> officeList = manageOfficeService.list();
        return AjaxResult.success(officeList);
    }

    @PostMapping("/insertOffice")
    public AjaxResult insertOffice(@RequestBody Office office){
        System.out.println(office);
        return AjaxResult.success(manageOfficeService.save(office));
    }

    @PostMapping("/updateOffice")
    public AjaxResult updateOffice(@RequestBody Office office){
        return AjaxResult.success(manageOfficeService.updateById(office));
    }

    @GetMapping("/selectOfficeByID")
    public AjaxResult selectOfficeByID(Office office){
        return AjaxResult.success(manageOfficeService.getById(office));
    }
}
